home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13742 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.iadfw.net!usenet
  2. From: Mark Nelson <markn@airmail.net>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: fast find algorithm
  5. Date: Tue, 09 Apr 1996 22:12:22 -0500
  6. Organization: Guest user
  7. Message-ID: <316B2716.4993@airmail.net>
  8. References: <Dp8wE6.8DG@cix.compulink.co.uk> <PdvZxMlyZE9U088yn@ime.usp.br> <4k9ggs$4ov@news1.mnsinc.com> <4kbrg8$luu@druid.borland.com>
  9. NNTP-Posting-Host: dal13-04.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB2 (Win95; I)
  14.  
  15. Pete Becker wrote:
  16. > In article <4k9ggs$4ov@news1.mnsinc.com>, huang@mnsinc.com says...
  17. > >
  18. > >Rogerio Brito (rbrito@ime.usp.br) wrote:
  19. > >: huang@mnsinc.com (Szu-Wen Huang) wrote:
  20. > >: >Falstaff (falstaff@xs4all.nl) wrote:
  21. > >: >...
  22. > >: >: Hashing is slightly slower than straight table lookup and can't be
  23. > >: >: used when you want to delete elements from your table.
  24. > >: >...
  25. > >
  26. > >: >Hashing can't be used when you want to delete elements?  Please explain.
  27. > >
  28. >     It depends on what you use to resolve conflicting hash values for different
  29. > elements. If you resolve conflicts by rehashing, or by moving to the next
  30. > available entry in the hash array, or any other mechanism that uses the array
  31. > itself as the storage location for the conflicting value, then you can't delete
  32. > items, cause once you do there's no way to get to the ones that used to
  33. > conflict. The first one you try will map to your now-empty location, and it'll
  34. > look like it wasn't found.
  35. >     If you use a linked list at each array location to resolve conflicts then
  36. > you can delete elements.
  37.  
  38. Knuth gives an algorithm for deleting elements from a table when using linear probing, 
  39. and it's pretty easy to see how that would work.  I'm not sure there is a practical 
  40. way to remove elements when using a secondary hash probe...
  41.  
  42. Mark Nelson
  43. http://web2.airmail.net/markn
  44.